package workspace;

import java.util.Scanner;
//携程最后一题
public class test55 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int q = scanner.nextInt();
        scanner.nextLine();
        int[][] mat = new int[n+2][m+2];
        String[] arr = new String[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextLine();
        }
        for (int i = 0; i < q; i++) {
            int x1 = scanner.nextInt();
            int y1 = scanner.nextInt();
            int x2 = scanner.nextInt();
            int y2 = scanner.nextInt();
            mat[x1][y1] +=1;
            mat[x1][y2 + 1] -= 1;
            mat[x2+1][y1] -= 1;
            mat[x2+1][y2+1]+=1;

        }
        for (int i = 1; i <= m+1; i++) {
            mat[0][i] += mat[0][i-1];
        }
        for(int i = 1;i<=n+1;i++){
            mat[i][0]+= mat[i-1][0];
        }
        for (int i = 1; i <= n+1; i++) {
            for (int j = 1; j <= m+1; j++) {
                mat[i][j] = mat[i-1][j] + mat[i][j-1]-mat[i-1][j-1];
            }
        }

        for (int i = 1; i <= n; i++) {
            StringBuilder sb = new StringBuilder();
            for (int j = 1; j <= m; j++) {
                if(mat[i][j]%2==0){
                    sb.append(arr[i-1].charAt(j-1));
                }else {
                    char c = arr[i-1].charAt(j-1);
                    if(Character.isUpperCase(c)){
                        sb.append(Character.toLowerCase(c));
                    }else{
                        sb.append(Character.toUpperCase(c));
                    }
                }
            }
            System.out.println(sb.toString());
        }

    }
}
